/*Version 1.0*/
#include "Animation.h"
#include "Scenario.h"

/*Contient la forme*/
ClutterActor * dessins;

/*Fonction interne qui execute la translation*/
static void GD(ClutterTimeline *timeline, gint frame_num, gpointer data)
{
  Marqueur * m=(Marqueur*)data;
  gdouble vitesse,acceleration;
  
  vitesse = m->vitesse;
  acceleration = m->acceleration;
  vitesse = vitesse + acceleration;
  clutter_actor_move_by(dessins,vitesse,0);
}

void DeplacementGD(ClutterTimeline *timeline,gchar * marker_name,gint msecs,gpointer data)
{
  Marqueur * m=(Marqueur*)data;
  
  timeline = clutter_timeline_new(m->duree);
  clutter_timeline_set_repeat_count(timeline,0);
  clutter_timeline_start(timeline);
  
  g_signal_connect(timeline,"new-frame",G_CALLBACK(GD),(Marqueur*)m); 
}

static void HB(ClutterTimeline *timeline, gint frame_num, gpointer data)
{
  Marqueur * m=(Marqueur*)data;
  gdouble vitesse,acceleration;

  vitesse = m->vitesse;
  acceleration = m->acceleration;
  vitesse = vitesse + acceleration;
  clutter_actor_move_by (dessins,0,vitesse);
}

void DeplacementHB(ClutterTimeline *timeline,gchar * marker_name,gint msecs,gpointer data)
{
  Marqueur * m=(Marqueur*)data;
  
  timeline = clutter_timeline_new(m->duree);
  clutter_timeline_set_repeat_count(timeline,0);
  clutter_timeline_start(timeline);
  
  g_signal_connect(timeline,"new-frame",G_CALLBACK(HB),(Marqueur*)m);
}

static void CDX(ClutterTimeline *timeline, gint frame_num, gpointer data)
{
  Marqueur * m=(Marqueur*)data;
  gdouble vitesse,acceleration;

  vitesse = m->vitesse;
  acceleration = m->acceleration;
  vitesse = vitesse + acceleration;
  
  clutter_actor_set_scale(dessins,vitesse,1);
}

void ChangementDechelleX(ClutterTimeline *timeline,gchar * marker_name,gint msecs,gpointer data)
{
  Marqueur * m=(Marqueur*)data;

  timeline = clutter_timeline_new(m->duree);
  clutter_timeline_set_repeat_count(timeline,0);
  clutter_timeline_start(timeline);

  g_signal_connect(timeline,"new-frame",G_CALLBACK(CDX),(Marqueur*)m);
}

static void RZ(ClutterTimeline *timeline, gint frame_num, gpointer data)
{
  Marqueur * m=(Marqueur*)data;
  gdouble vitesse,acceleration;

  vitesse = m->vitesse;
  acceleration = m->acceleration;
  vitesse = vitesse + acceleration;

  clutter_actor_set_rotation(dessins,CLUTTER_Z_AXIS,vitesse*5, 0, 0,0);
}
void RotationZ(ClutterTimeline *timeline,gchar * marker_name,gint msecs,gpointer data)
{
  Marqueur * m=(Marqueur*)data;

  timeline = clutter_timeline_new(m->duree);
  clutter_timeline_set_repeat_count(timeline,0);
  clutter_timeline_start(timeline);

  g_signal_connect(timeline,"new-frame",G_CALLBACK(RZ),(Marqueur*)m);
}
